<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">资产分组明细管理</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产编码：</text></view>
                  <input  placeholder="请输入资产编码" v-model="model.assetCoding"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产名称：</text></view>
                  <input  placeholder="请输入资产名称" v-model="model.assetName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">规格型号：</text></view>
                  <input  placeholder="请输入规格型号" v-model="model.spec"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">类别id：</text></view>
                  <input  placeholder="请输入类别id" v-model="model.categoryId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">所属公司：</text></view>
                  <input  placeholder="请输入所属公司" v-model="model.company"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">所属部门：</text></view>
                  <input  placeholder="请输入所属部门" v-model="model.dept"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">所属人：</text></view>
                  <input  placeholder="请输入所属人" v-model="model.owner"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">使用人：</text></view>
                  <input  placeholder="请输入使用人" v-model="model.userer"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">使用年限：</text></view>
                  <input  placeholder="请输入使用年限" v-model="model.useTime"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">原值：</text></view>
                  <input  placeholder="请输入原值" v-model="model.original"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">净值：</text></view>
                  <input  placeholder="请输入净值" v-model="model.netWorth"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">status：</text></view>
                  <input  placeholder="请输入status" v-model="model.status"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">url：</text></view>
                  <input  placeholder="请输入url" v-model="model.url"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">所属部门名称：</text></view>
                  <input  placeholder="请输入所属部门名称" v-model="model.deptName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">简单部门名称：</text></view>
                  <input  placeholder="请输入简单部门名称" v-model="model.simpleDeptName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">盘点方式，1扫码，2直盘：</text></view>
                  <input type="number" placeholder="请输入盘点方式，1扫码，2直盘" v-model="model.inventoryType"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">计划使用年：</text></view>
                  <input  placeholder="请输入计划使用年" v-model="model.planUserYear"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">计划使用月：</text></view>
                  <input  placeholder="请输入计划使用月" v-model="model.planUserMonth"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产地址：</text></view>
                  <input  placeholder="请输入资产地址" v-model="model.assetsLocation"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">分组id：</text></view>
                  <input type="number" placeholder="请输入分组id" v-model="model.groupId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">分组名称：</text></view>
                  <input  placeholder="请输入分组名称" v-model="model.groupName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">类别名称：</text></view>
                  <input  placeholder="请输入类别名称" v-model="model.categoryName"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "AssetsGroupItemForm",
        components:{myDate},
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/assets/assetsGroupItem/queryById",
                  add: "/assets/assetsGroupItem/add",
                  edit: "/assets/assetsGroupItem/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
